package com.acquisition.service.impl;

import com.acquisition.entity.DayData;
import com.acquisition.mapper.DayDataMapper;
import com.acquisition.service.DayDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @title：
 * @author：Yu
 * @create：2023-04-15 20:31
 * @description：
 */
@Service
public class DayDataMapperImpl implements DayDataService {
    @Autowired
    DayDataMapper dayDataMapper;

    @Override
    public int save(DayData dayData) {
        dayDataMapper.save(dayData);
        Integer id = dayData.getId();
        return id;
    }

    @Override
    public int remove(int id) {
        int remove = dayDataMapper.remove(id);
        if (remove > 0) {
            return 1;
        } else {
            return -1;
        }
    }

    @Override
    public int update(DayData dayData) {
        int update = dayDataMapper.update(dayData);
        if (update > 0) {
            return 1;
        } else {
            return -1;
        }
    }

    @Override
    public DayData get(int id) {
        return dayDataMapper.get(id);
    }

    @Override
    public List<DayData> queryByExample(Map<String, Object> param) {
        List<DayData> dayData = dayDataMapper.queryByExample(param);
        if (dayData != null && dayData.size() > 0) {
            return dayData;
        } else {
            return null;
        }
    }

    @Override
    public int count(Map<String, Object> param) {
        int count = dayDataMapper.count(param);
        return count;
    }

    @Override
    public int removeAll() {
        int i = dayDataMapper.removeAll();
        if (i > 0) {
            return 1;
        } else {
            return -1;
        }
    }

    @Override
    public int updateFlag(int serverNum, int id) {
        int i = dayDataMapper.updateFlag(serverNum, id);
        if (i > 0) {
            return 1;
        } else {
            return -1;
        }
    }

    @Override
    public int updateQn(String qn, int id) {
        int i = dayDataMapper.updateQn(qn, id);
        if (i > 0) {
            return 1;
        } else {
            return 0;
        }
    }
}
